/*
 * @Author: xiguan
 * @Email: xiguan.teng@qq.com
 * @Version: 1.0
 * @Date: 2022-07-31 11:49:11
 * @LastEditTime: 2022-07-31 12:12:52
 */


#include "PairTest.h"

namespace MySTL{
	namespace PairTest{
		template<class Container1, class Container2>
		static inline bool container_equal(const Container1& pair1, const Container2& pair2){
			return (pair1.first == pair2.first && pair1.second == pair2.second);
		}
		void testCase1(){
			stdPair<int> p1(5, 5);
			tsPair<int> p2(5, 5);
			assert(container_equal(p1, p2));
            std::cout << "pass 1" << std::endl;
		}
		void testCase2(){
			stdPair<int> p1(stdPair<int>(0, 0));
			tsPair<int> p2(tsPair<int>(0, 0));
			assert(container_equal(p1, p2));
		}
		void testCase3(){
			stdPair<std::string> temp1 = std::make_pair(std::string("xiguan"), std::string("xiguan"));
			stdPair<std::string> p1 = temp1;
		
			tsPair<std::string> temp2 = MySTL::make_pair(std::string("xiguan"), std::string("xiguan"));
			tsPair<std::string> p2 = temp2;
		
			assert(container_equal(p1, p2));
		}
		void testCase4(){
			MySTL::pair<int, char> foo(10, 'z');
			MySTL::pair<int, char> bar(90, 'a');
		
			assert(!(foo == bar));
			assert(foo != bar);
			assert(foo < bar);
			assert(!(foo > bar));
			assert(foo <= bar);
			assert(!(foo >= bar));
		}
		void testCase5(){
			MySTL::pair<int, char> foo(10, 'z');
			MySTL::pair<int, char> bar(90, 'a');
		
			// foo.swap(bar);
            // bar.swap( foo );
            swap( foo, bar );

            printf( "%d %c\n", foo.first, foo.second);
            printf( "%d %c\n", bar.first, bar.second);
		
			assert(foo.first == 90 && foo.second == 'a');
			assert(bar.first == 10 && bar.second == 'z');
		}


		void testAllCases(){
			testCase1();
			testCase2();
			testCase3();
			// testCase4();
			testCase5();
		}
	}
}